﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class Employees_EmployeeDetail_Choose : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["mode"] != null)
            {
                if (Request["mode"].ToString() != "")
                {
                    string[] Mode = Request["mode"].ToString().Split(',');

                    

                    for (int i = 0; i < Mode.Length; i++)
                    {
                        for (int j = 0; j < ChkChoose.Items.Count; j++)
                        {
                            if (Mode[i].ToString() == ChkChoose.Items[j].Value)
                            {
                                ChkChoose.Items[j].Enabled = false;
                                ChkChoose.Items[j].Selected = false;
                            }

                        }
                    }


                }

            }
        }
    }

    protected void Back_Click(object sender, EventArgs e)
    {
        StringBuilder sbr = new StringBuilder();
        string b = "";
        for (int j = 0; j < ChkChoose.Items.Count; j++)
        {
            if (!ChkChoose.Items[j].Selected)
            {
                sbr.Append(ChkChoose.Items[j].Value + ",");
            }
        }

        if (sbr.Length > 0)
        {
            b = Server.UrlEncode(sbr.ToString().Substring(0, sbr.ToString().Length - 1));
        }

        if ((b.Split(',')).Length == ChkChoose.Items.Count)
        {
            return;
        }

        if (Request["action"].ToString() == "self")
        {

            ClientScript.RegisterStartupScript(GetType(), "Msg", "parent.location.href='EmployeeDetail.aspx?action=self&mode=" + b + "&do=true" + "&eid=" + Convert.ToInt32(Srvtools.CliUtils.GetValue("_UserCode")[1]).ToString() + "'", true);

        }
        else
        {
            ClientScript.RegisterStartupScript(GetType(), "Msg", "parent.location.href='EmployeeDetail.aspx?action=" + Request["action"].ToString() + "&mode=" + b + "&do=true" + "&eid=" + Request["eid"].ToString() + "'", true);

        }

    }
}
